/*
 * @Author: [wsn] [1741415861@qq.com]
 * @Date: 2023-05-08 13:28:01
 * @LastEditors: [wsn] [1741415861@qq.com]
 * @LastEditTime: 2023-05-26 11:13:51
 * @FilePath: \202304fgs_project\src\components\threejsTools\Tools\LoadFbx.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader";

// <a-button type="text" class="returnbtnsec1" @click="splitmodel">拆解</a-button>

/**加载可用于拆解的fbx模型 */
export default function modelsAnimate(url) {
    ///url:sanjiaomian/DXD-sanjiaomian.fbx
    var loader = new FBXLoader(); //创建一个FBX加载器
    loader.load(url, function (obj) {
        console.log(obj, "大雄殿模型我加载了"); //查看加载后返回的模型对象
        obj.scale.set(0.01, 0.01, 0.01);
        obj.translateY(-2)
        window.globalmodel = obj;
        // console.log(obj, 'obj');
        // window.fbxmodels = obj;
        obj.traverse((child) => {
            console.log(child, "child");
            if (child.isMesh || child.isGroup) {
                child.frustumCulled = false;
                child.position.set(0, -10, -20);
            }
        });
        window.threescene.add(obj);
        // 适当平移fbx模型位置
        // obj.translateY(-80);
    });
}
